<template>
	<view class="mainbgc" v-if="pageShow">
		<header-top :messageInfo="{typeFlag:true,message:titletext,liner:false}"></header-top>
		<view class="mainpadding2">
			<view class="flexcenter" v-if="!list.data.length">
				<view class="placeholderimage"></view>
			</view>
			<view class="mainpadding_top ffffff radius flexbetween" style="position: relative;" v-for="item in list.data" :key="item.id" @click="jumpdetail(item.id)">
				<view>
					<view class="leftdetail">{{item.title}}</view>
					<view class="leftdetail margin_top2">{{item.createtime_text}}</view>
				</view>
				<view class="flexright">
					<view class="righticon2"></view>
				</view>
				<view class="hongdian" v-show="!item.is_read"></view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type:"",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				pageShow:false
			}
		},
		onLoad(options) {
			this.type = options.type
			
		},
		onShow() {
			this.init()
		},
		computed:{
			// 类型:1=政策发文,2=公司制度,3=最新通知,4=平台信息
			titletext(){
				if(this.type==1)return "政策发文"
				if(this.type==2)return "公司制度"
				if(this.type==3)return "最新通知"
				if(this.type==4)return "平台信息"
			}
		},
		methods: {
			init(isPage, page) {
				let _this = this;
				httpRequest.request('/dhtapi/index/getPtNotice', 'GET', {
					page: page || 1,
					limit: _this.limit,
					type:this.type
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = resList
							_this.list.data = resList.data;
						}
					}
					this.pageShow = true
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumpdetail(id){
				uni.navigateTo({
					url:"/pages/homepage/news/kaidan?id=" + id
				})
			}
		}
	}
</script>

<style>
	.hongdian{
		width: 15rpx;
		height: 15rpx;
		background-color: #ff0000;
		border-radius: 50rpx;
		position: absolute;
		top: 30rpx;
		right: 30rpx;
	}
	.itembox{
		display: flex;
		align-items: flex-start;
		justify-content: space-between;
	}
	.smalltext{
		font-size: 28rpx;
		margin-right: 30rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
	.leftdetail{
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		line-height: 33rpx;
		width: 300rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	.rightdetail{
		flex: 3;
	}
	.jiaobiao {
		background-color: #ff0000;
		border-radius: 50rpx;
		width: 15rpx;
		height: 15rpx;
		margin-right: 30rpx;
	}
</style>
